package com.chb.microservice.provider.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.cbh.api.model.ApiResult;
import com.chb.microservice.provider.hystrix.PlatePrefixHystrixWrapped;
import com.chb.microservice.provider.model.PlatePrefix;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@RefreshScope
@Api(description = "车牌前缀管理")
@RestController
@RequestMapping("/sign/v3/plate/prefix")
public class PlatePrefixController {
	@Autowired
	PlatePrefixHystrixWrapped platePrefixHystrixWrapped;

	/**
	 * 保存车牌前缀信息
	 * 
	 * @param product
	 * @return
	 */
	@ApiOperation(value = "车牌前缀信息保存", httpMethod = "POST")
	@RequestMapping(value = "", method = RequestMethod.POST, produces = "application/json")
	public ApiResult<String> save(
			@ApiParam(value = "车牌前缀信息", required = true) @RequestBody(required = true) PlatePrefix ob) {
		return platePrefixHystrixWrapped.save(ob);
	}

	/**
	 * 获取全部车牌前缀信息
	 * 
	 * @return
	 */
	@ApiOperation(value = "获取全部车牌前缀信息", httpMethod = "GET")
	@RequestMapping(value = "", method = RequestMethod.GET, produces = "application/json")
	public ApiResult<List<PlatePrefix>> getAll() {
		return platePrefixHystrixWrapped.getAll();
	}

	/**
	 * 获取车牌前缀信息
	 * 
	 * @param proId
	 * @return
	 */
	@ApiOperation(value = "获取车牌前缀信息", httpMethod = "GET")
	@ApiImplicitParams({ @ApiImplicitParam(paramType = "path", name = "id", dataType = "String", required = true) })
	@RequestMapping(value = "{id}", method = RequestMethod.GET, produces = "application/json")
	public ApiResult<PlatePrefix> getOne(@PathVariable("id") String id) {
		return platePrefixHystrixWrapped.getOne(id);
	}

	/**
	 * 删除车牌前缀信息
	 * 
	 * @param proId
	 * @return
	 */
	@ApiOperation(value = "删除车牌前缀信息", httpMethod = "DELETE")
	@ApiImplicitParams({ @ApiImplicitParam(paramType = "path", name = "id", dataType = "String", required = true) })
	@RequestMapping(value = "{id}", method = RequestMethod.DELETE, produces = "application/json")
	public ApiResult<Boolean> delete(@PathVariable("id") String id) {
		return platePrefixHystrixWrapped.delete(id);
	}
}
